package com.sgx.learning.luban.homework.attributes;

import com.sgx.learning.luban.homework.basictype.U2;
import com.sgx.learning.luban.homework.constantpool.ConstantPoolInfo;
import lombok.Data;

import java.io.IOException;
import java.io.InputStream;

@Data
public class Exceptions extends AttributeInfo {

    private short numberOfExceptions;
    private short[] exceptionIndexTable;
    @Override
    public void read(InputStream is, ConstantPoolInfo[] constantPoolInfos) throws IOException {
        this.numberOfExceptions = U2.read(is).getValue();
        if(this.numberOfExceptions > 0) {
            exceptionIndexTable = new short[numberOfExceptions];
            for (int i = 0; i < numberOfExceptions; i++) {
                exceptionIndexTable[i] = U2.read(is).getValue();
            }
        }
    }
}
